package com.huan.ddl;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class NewTestAPI {


    public static boolean isTableExist(String table) throws IOException {


        // 创建上下文对象
        Configuration conf = HBaseConfiguration.create();
        conf.set( "hbase.zookeeper.quorum","Bigdata01,Bigdata02,Bigdata03" );


        //连接工厂
        Connection connection = ConnectionFactory.createConnection( conf );


        //创建管理员
        Admin admin = connection.getAdmin();


        //看源码即可
        boolean exists = admin.tableExists( TableName.valueOf( table ) );

        //关闭资源
        admin.close();
        
        //返回结果
        return  exists;

    }





    public static void main(String[] args) throws IOException {
      boolean b =  isTableExist("student");

      System.out.println(b);

    }
}
